<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/11/10
 * Time: 10:31
 */
namespace Trade\Controller;
use Admin\Controller\CommonController;
use Trade\Model\TradeModel;

class TradeController extends CommonController{
    private $trade_db;
    function _initialize(){
        parent::_initialize();
        $this->trade_db = new TradeModel();
    }


    function index($page=1, $rows=10, $search = array()){
        if (IS_POST) {
            $map   = array();
            $limit = ($page - 1) * $rows . "," . $rows;
            $total = $this->trade_db->where($map)->count();
            $list  = $total ? $this->trade_db->public_list(0, $map, $limit) : array();
            foreach ($list as $key=>$value){
                //格式化时间
                $list[$key]['create_time'] = date('Y-m-d H:i', $value['create_time']);
            }
            $this->ajaxReturn(array('total'=>$total, 'rows'=>$list));
        }else {

            $this->currentpos = $this->menu_db->currentPos(I('menuid'));  //栏目位置
            $this->display('index');
        }
    }
}